import matplotlib.pyplot as plt
import numpy as np
import pandas as pd  # 是python的一个数据分析包

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

df = pd.read_excel("compare.xlsx", engine='openpyxl')
Cl = np.array(df.iloc[:, [1, 3, 5]])
Cd = np.array(df.iloc[:, [2, 4, 6]])

x = range(1, 5, 1)

# Cl=========
plt.figure()
plt.xticks(range(1, 5, 1), labels=['1/2', '1/3', '1/4', '1/5'])
plt.title('$R^2$的变化(随训练样本数量降低)', fontsize=15)
plt.xlabel('训练样本/总样本(风洞数据)', fontsize=15)
plt.ylabel('$R^2$(Cl)', fontsize=15)
plt.plot(x, Cl[:, 0], label='TrAdaBoost.R2', linestyle='--', marker='s', markerfacecolor='white')
plt.plot(x, Cl[:, 1], label='CDM', linestyle='-.', marker='>', markerfacecolor='white')
plt.plot(x, Cl[:, 2], label='Fine_Tune', linestyle=':', marker='*', markerfacecolor='white')
plt.legend(loc=0, frameon=False)
plt.savefig('Cl-R2对比.svg')
plt.show()

# Cd=========
plt.figure()
plt.xticks(range(1, 5, 1), labels=['1/2', '1/3', '1/4', '1/5'])
plt.title('$R^2$的变化(随训练样本数量降低)', fontsize=15)
plt.xlabel('训练样本/总样本(风洞数据)', fontsize=15)
plt.ylabel('$R^2$(Cd)', fontsize=15)
plt.plot(x, Cd[:, 0], label='TrAdaBoost.R2', linestyle='--', marker='s', markerfacecolor='white')
plt.plot(x, Cd[:, 1], label='CDM', linestyle='-.', marker='>', markerfacecolor='white')
plt.plot(x, Cd[:, 2], label='Fine_Tune', linestyle=':', marker='*', markerfacecolor='white')
plt.legend(loc=0, frameon=False)
plt.savefig('Cd-R2对比.svg')
plt.show()
